import java.util.Vector;

public final class cls_ae
        implements inf_m {

    private MainThread mainThread;
    cls_h a;
    private Vector vector;
    cls_h b[];

    cls_ae(MainThread thread) {
        mainThread = thread;
        vector = new Vector();
        b = new cls_h[75];
        b[19] = new cls_h(thread, (short) 118, (short) 119, (short) 3, (short) 2, 2);
        b[17] = new cls_h(thread, (short) 120, new short[0], (short) 3, (short) 4, 0);
    }

    final void a() {
        d();
        mainThread.a();
        b[1] = new cls_h(mainThread, (short) 122, (short) 160, (short) 3, (short) 2, 2);
        b[3] = new cls_h(mainThread, (short) 195, (short) 194, (short) 3, (short) 2, 2);
        b[2] = new cls_h(mainThread, (short) 196, (short) 198, (short) 3, (short) 2, 2);
        mainThread.a();
        b();
        b[8] = new cls_h(mainThread, (short) 5, (short) 3, (short) 4, 8);
        b[8].c = 3;
        mainThread.a();
        if (mainThread.cw > 0) {
            short aword0[] = new short[mainThread.cw * 3];
            byte byte0 = 0;
            for (int i = 0; i < mainThread.cw * 3; i += 3) {
                if (mainThread.cv[i / 3][2].equals("TET"))
                    byte0 = 0;
                else if (mainThread.cv[i / 3][2].equals("SIM"))
                    byte0 = 3;
                else if (mainThread.cv[i / 3][2].equals("HAP"))
                    byte0 = 6;
                aword0[i] = 1;
                aword0[i + 1] = 1;
                aword0[i + 2] = (short) (byte0 + 266);
            }

            b[14] = new cls_h(mainThread, (short) 206, aword0, (short) 3, (short) 4, 10);
            b[14].A = new short[mainThread.cw][];
            for (int j = 0; j < mainThread.cw; j++) {
                if (mainThread.cv[j][2].equals("TET"))
                    byte0 = 0;
                else if (mainThread.cv[j][2].equals("SIM"))
                    byte0 = 1;
                else if (mainThread.cv[j][2].equals("HAP"))
                    byte0 = 2;
                b[14].A[j] = (new short[]{
                        (short) (byte0 + 170),
                        1
                });
            }

            if (mainThread.cv[0][0] == null)
                b[14].d = 1;
            b[16] = new cls_h(mainThread, (short) 206, (short) 207, (short) 6, (short) 4, 2);
        }
        b[15] = new cls_h(mainThread, (short) 206, (short) 273, (short) 3, (short) 2, 2);
        mainThread.a();
        b[11] = new cls_h(mainThread, (short) 243, new short[]{
                156, 158
        }, (short) 3, (short) 4, 0);
        b[12] = new cls_h(mainThread, (short) 243, new short[10], (short) 3, (short) 4, 7);
        b[13] = new cls_h(mainThread, (short) 243, new short[10], (short) 3, (short) 4, 7);
        mainThread.a();
        b[21] = new cls_h(mainThread, (short) 86, (short) 101, (short) 6, (short) 4, 2);
        Vector vector;
        (vector = new Vector()).addElement(new Short((short) 156));
        vector.addElement(new Short((short) 158));
        vector.addElement(new Short((short) 162));
        vector.addElement(new Short((short) 244));
        short aword1[] = new short[vector.size()];
        for (int k = 0; k < vector.size(); k++) {
            aword1[k] = ((Short) vector.elementAt(k)).shortValue();
        }
        b[6] = new cls_h(mainThread, (short) 164, aword1, (short) 3, (short) 4, 0);
        mainThread.a();
    }

    final void b() {
        Vector vector = new Vector();
        (vector).addElement(new Short((short) 118));
        vector.addElement(new Short((short) 234));
        if (mainThread.enableTAF && mainThread.recordManager.language != null && mainThread.recordManager.language.equals("en")) {
            vector.addElement(new Short((short) 260));
        }
        vector.addElement(new Short((short) 197));
        short aword0[] = new short[vector.size()];
        for (int i = 0; i < vector.size(); i++) {
            aword0[i] = ((Short) vector.elementAt(i)).shortValue();
        }
        b[7] = new cls_h(mainThread, (short) 167, aword0, (short) 3, (short) 4, 0);
        b[7].z[0] = (new short[]{
                169, 168
        });
        b[7].y[0] = mainThread.recordManager.a ? 1 : 0;
        b[7].z[1] = (new short[]{
                169, 168
        });
        b[7].y[1] = mainThread.recordManager.c ? 0 : 1;
    }

    final void c() {
        int word0 = mainThread.R != 4 ? 4 : 1;
        Vector vector = new Vector();
        (vector).addElement(new Short((short) 156));
        if (mainThread.recordManager.r) {
            vector.addElement(new Short((short) 158));
        }
        if (!mainThread.aR) {
            vector.addElement(new Short((short) 3));
        }
        short aword0[] = new short[vector.size()];
        for (int i = 0; i < aword0.length; i++) {
            aword0[i] = ((Short) vector.elementAt(i)).shortValue();
        }
        b[0] = new cls_h(mainThread, (short) 193, aword0, (short) 3, (short) word0, 0);
        b[0].c = 22;
    }

    final void d() {
        Vector vector = new Vector();
        if (mainThread.R != 4 && mainThread.R >= 0) {
            vector.addElement(new Short((short) 123));
        }
        vector.addElement(new Short((short) 191));
        if (Spore.e) {
            vector.addElement(new Short((short) 206));
        }
        vector.addElement(new Short((short) 167));
        vector.addElement(new Short((short) 243));
        vector.addElement(new Short((short) 164));
        vector.addElement(new Short((short) 165));
        if ((mainThread.mgImpl_wap || mainThread.mgImpl_static) && mainThread.cw > 0) {
            vector.addElement(new Short((short) 206));
        }
        vector.addElement(new Short((short) 122));
        short aword0[] = new short[vector.size()];
        for (int i = 0; i < vector.size(); i++) {
            aword0[i] = ((Short) vector.elementAt(i)).shortValue();
        }

        b[5] = new cls_h(mainThread, (short) 192, aword0, (short) 3, (short) 4, 0);
    }

    final void a(cls_h h1, boolean flag) {
        if (a != null) {
            a.b();
        }
        a = h1;
        if (!flag) {
            vector.addElement(a);
        }
        a.a();
        h1.e = 0;
        a.a = -1;
    }

    final void a(int i, boolean flag) {
        a(b[i], flag);
        a.a = i;
    }

    final void a(cls_h h1) {
        a(h1, false);
    }

    final void a(int i) {
        a(i, false);
    }

    final void b(int i) {
//        mainThread.cs.a(100, 0, 0L, mainThread.bP);
        mainThread.cs.a(100, 0, 0L, MainThread.bP);
        vector.removeAllElements();
        a(i, false);
        a.a = i;
        if (mainThread.gameState != 0) {
            mainThread.gameState = 6;
        }
    }

    final void e() {
        if (vector.size() > 1) {
            if (a.equals(vector.lastElement())) {
                vector.removeElementAt(vector.size() - 1);
            }
            a.b();
            a = (cls_h) vector.lastElement();
            if (a.fld_b_int == 8) {
                a.c();
                return;
            } else {
                a.a();
                return;
            }
        }
        if (vector.size() == 1 && !a.equals(vector.lastElement())) {
            a.b();
            a = (cls_h) vector.lastElement();
            if (a.fld_b_int == 8) {
                a.c();
                return;
            }
            a.a();
        }
    }
}